const validateUsername = (rule, value, callback) => {
  if (!value) {
    callback(new Error('请输入用户名'))
  } else {
    callback()
  }
}
const validateCaptcha = (rule, value, callback) => {
  if (!value) {
    callback(new Error('请输入验证码'))
  } else {
    callback()
  }
}
const validateNickName = (rule, value, callback) => {
  if (!value) {
    callback(new Error('请输入昵称'))
  } else {
    callback()
  }
}
const validateGroupName = (rule, value, callback) => {
  if (!value) {
    callback(new Error('请输入群组名称'))
  } else {
    callback()
  }
}

const validatePassword = (rule, value, callback) => {
  if (!value) {
    callback(new Error('请输入6位数的密码'))
  } else if (value.length < 6 || value.length > 16) {
    callback(new Error('请输入6位数的密码'))
  } else {
    callback()
  }
}
const validateCompany = (rule, value, callback) => {
  if (!value) {
    callback(new Error('请选择公司'))
  } else {
    callback()
  }
}
const validateDepartment = (rule, value, callback) => {
  if (!value) {
    callback(new Error('请选择部门'))
  } else {
    callback()
  }
}
function code(phone) {
  const telVerify = /^1[3456789]{1}\d{9}$/
  // 验证是验证手机号码为11位，且以1开头。
  return telVerify.test(phone)
}
export {
  validateUsername,
  validatePassword,
  validateNickName,
  validateCompany,
  validateDepartment,
  validateGroupName,
  validateCaptcha
}
